package com.kuangqiyuan.yatzygame;

import com.kuangqiyuan.yatzygame.exception.PlayRecordException;

import java.util.List;

/**
 * 一局游戏的记录。
 *
 * 规则：1）每次掷骰子记录都应该是 0<N<7 的整数
 */
public class Play {
  private int[] record;

  public Play(int[] in) throws PlayRecordException {
    this.record = new int[in.length];
    for (int i = 0; i < in.length; i++) {
      if (in[i] < 1 || in[i] > 6) {
        throw new PlayRecordException(String.format("Every record should be 0<N<7, but got: %d", in[i]));
      }
      this.record[i] = in[i];
    }
  }

  public int getRecord(int i) {
    return record[i];
  }

  public int[] getRecords() {
    int[] newRecord = new int[this.record.length];
    System.arraycopy(this.record, 0, newRecord, 0, this.record.length);

    return newRecord;
  }

  public int getLength() {
    return record.length;
  }
}
